//
//  HLLoginViewController.m
//  YueYue
//
//  Created by hulu001 on 2023/5/23.
//

#import "HLLoginViewController.h"
#import "HLLoginCategoryView.h"

@interface HLLoginViewController ()

@property (nonatomic, strong) UIImageView *backgroundImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) HLLoginCategoryView *loginCategoryView;
@end

@implementation HLLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColorBlack;
    [HLUIHelper showAlertMustAgreeInfo];
}

- (void)setupNavigationItems
{
    [super setupNavigationItems];
    self.title = @"";
    if ([HLRunTime shareInstance].isFood) {
        UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithImage:UIImageMake(@"nav_back_white") style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
        UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
        self.navigationItem.leftBarButtonItems = @[space, back];
    }
    
}

- (void)initSubviews
{
    [super initSubviews];
    
    self.backgroundImageView = [[UIImageView alloc] init];
    _backgroundImageView.image = UIImageMake([HLRunTime shareInstance].isFood?@"login_food_background":@"login_background");
    [self.view addSubview:_backgroundImageView];
    [_backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
    }];
    
    self.detailLabel = [[UILabel alloc] qmui_initWithFont:UIFontMediumMake(20) textColor:[UIColorWhite colorWithAlphaComponent:0.6]];
    _detailLabel.text = [HLRunTime shareInstance].isFood?@"越轻食，越健康，越轻盈":@"有你有我 超乎想象";
    _detailLabel.numberOfLines = 0;
    [_backgroundImageView addSubview:_detailLabel];
    [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(24);
        make.right.mas_equalTo(-40);
        make.bottom.mas_equalTo(-(74 - SafeAreaInsetsConstantForDeviceWithNotch.bottom));
    }];
    
    self.titleLabel = [[UILabel alloc] qmui_initWithFont:UIFontBoldMake(28) textColor:UIColorWhite];
    _titleLabel.text = @"欢迎来到越轻盈";
    _titleLabel.numberOfLines = 0;
    [_backgroundImageView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(_detailLabel);
        make.bottom.equalTo(_detailLabel.mas_top).offset(-8);
    }];
    
    self.loginCategoryView = [[HLLoginCategoryView alloc] init];
    [self.view addSubview:_loginCategoryView];
    [_loginCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.mas_equalTo(0);
        make.top.equalTo(_detailLabel.mas_bottom).offset(10);
    }];
    
    
    [_loginCategoryView.phoneButton addTarget:self action:@selector(quickLoginBtnAction) forControlEvents:UIControlEventTouchUpInside];
}

- (void)backAction
{
    [HLUIHelper setRootTabBar];
}

// 用户需要使用闪验一键登录时的方法
- (void)quickLoginBtnAction
{
    
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

- (UIImage *)qmui_navigationBarBackgroundImage
{
    return [UIImage qmui_imageWithColor:UIColorClear];
}

- (nullable UIColor *)qmui_navigationBarTintColor
{
    return UIColorWhite;
}

- (BOOL)shouldHideKeyboardWhenTouchInView:(UIView *)view
{
    return YES;
}
@end
